#include "gmock/gmock.h"
#include "SkipList.h"

using namespace LQLib;
using namespace testing;

using LKey = long long;
struct LComparator {
	int operator()(const LKey& a, const LKey& b) const {
		if (a < b) {
			return -1;
		} else if (a > b)
		{
			return 1;
		}
		else {
			return 0;
		}
	}
};

TEST(SkipList, create) {

	LComparator lcmp;
	SkipList<LKey, LComparator> lst(lcmp);

}

TEST(SkipList, insert) {
	LComparator lcmp;
	SkipList<LKey, LComparator> lst(lcmp);
	//LKey k = 2;
	//lst.insert(k);
	//auto val = lst.m_header->Next(0);
	//LKey s = 3;
	//for (int i = 30; i > 15; i-= 2)
	//{
	//	LKey k = i;
	//	lst.insert(k);
	//}
	//
	//for (auto iter = lst.m_header->Next(0); iter != nullptr; iter = iter->Next(0))
	//{
	//	std::cout << iter->key << " ";
	//}

	int step = 0;
	for (LKey i = 5000; i > 4900; --i)
	{
		lst.insert(i);
	}
	/*


		#include <iostream>
		std::cout << step << "\t times insert:\n";
		std::cout << "address: " << lst.m_header << "    value: header" << "\t";
		for (auto arr = 0; arr < lst.GetMaxHeight(); ++arr) {
			std::cout << "key[" << arr << "]" << lst.m_header->next_[arr] << "\t";
		}
		std::cout << std::endl;
		for (auto iter = lst.m_header->Next(0); iter != nullptr; iter = iter->Next(0))
		{

			std::cout << "address: " << iter << "    value:     " << iter->key << "\t";

			for (auto arr = 0;  arr < iter->next_.length(); ++arr)
			{
				std::cout << "key[" << arr << "]" << iter->next_[arr] << "\t";
			}
			std::cout << std::endl;
		}

		std::cout << "---------------------------------\n";



	*/

	ASSERT_EQ(true, lst.Contains(LKey(16000)));

}